/**
 * 
 */
package com.jiang.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @author Administrator
 * @第一个自定义拦截器
 */
@SuppressWarnings("serial")
public class InterceptorDemo extends AbstractInterceptor {

	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public void init() {
		System.out.println("-----拦截器InterceptorDemo初始化");
	}

	@Override
	public String intercept(ActionInvocation invokcation) throws Exception {
		System.out.println("拦截器中的属性值:" + this.name);
		System.out.println("invoke()方法调用之前");
		String res = invokcation.invoke();
		System.out.println("invoke()方法调用，返回地址映射:" + res);
		System.out.println("invoke()方法调用之后");
		return null;
//		return "forward.page"; // 经测试2.2.1版本这里设置没有效果，只能Action中设置
	}

	@Override
	public void destroy() {
		System.out.println("--------拦截器InterceptorDemo销毁");
	}
}
